/*
 * Meter.java
 *
 * Version 1.0
 * Copyright 2011 BobSoft Inc
 */
package edu.gatech.galaxy.model;

import java.io.Serializable;

/**
 * Represents a value with a current value and a maximum
 * 
 * @author Robert
 * @version 1.0
 *
 */
public class Meter implements Serializable {
    public static final double DEFAULT_VALUE = 0.0;
     private double currentValue;
     private double initialValue;
     
     public Meter() {
         currentValue = DEFAULT_VALUE;
         initialValue = DEFAULT_VALUE;
     }
     
     public Meter(double currVal) {
         currentValue = currVal;
         initialValue = DEFAULT_VALUE;
     }
     
     public Meter(double currVal, double initVal) {
         currentValue = currVal;
         initialValue = initVal;
     }
     
     public void Set(double currVal, double initVal) {
         currentValue = currVal;
         initialValue = initVal;
     }

    /**
     * @return the currentValue
     */
    public double getCurrentValue() {
        return currentValue;
    }

    /**
     * @param currentValue the currentValue to set
     */
    public void setCurrentValue(double currentValue) {
        this.currentValue = currentValue;
    }

    /**
     * @return the initialValue
     */
    public double getInitialValue() {
        return initialValue;
    }

    /**
     * @param initialValue the initialValue to set
     */
    public void setInitialValue(double initialValue) {
        this.initialValue = initialValue;
    }
    
    public void resetCurrent() {
        currentValue = DEFAULT_VALUE;
    }
    
    public void reset() {
        currentValue = DEFAULT_VALUE;
        initialValue = DEFAULT_VALUE;
    }
    
    public void addToCurrent(double amount) {
        currentValue += amount;
    }
    
    public void clampCurrentToRange(double min, double max) {
        currentValue = Math.max(Math.min(currentValue, max), min);
    }
     
    public void backPropogate() {
        initialValue = currentValue;
    }
     
}
